#!/usr/bin/env python
# coding: utf-8

#sys._getframe().f_back.f_code.co_name

from engine.screen import *
# debugInfo("checknow ",sys._getframe().f_code.co_name)

class PERSON:
    """PERSON"""

    screenNow  = ""
    type = ""
    sno=""

    def __init__(self):
        self.DEBUG = True

        debugInfo("__init__")

    def __init__(self,type,sno):
        self.DEBUG = True
        self.type = type
        self.sno = sno
        self.screenNow = screenClass(type,sno)
        debugInfo("__init__")

    def init(self):
        debugInfo("",sys._getframe().f_back.f_code.co_name)
        pass
    def getTask(self):
        debugInfo("get task form a file to parse it  and thinking")

    def lookScreen(self):
        self.screenNow.getCurrentScreen()

    def screenJustOne(self):
        #初步判断是个啥图
        con = 0.01
        self.lookScreen()
        if not os.path.exists(self.screenNow.backNScreen[0]):#self.screenNow.back1Screen =="":
            #ret,con=isSameScreen("./shouji/"+self.currentHandset+"/__init__.png" ,self.screenNow.currentScreen,self.currentHandset)
            pass
        else:
            if os.path.getsize(self.screenNow.backNScreen[0])>100:
                try:
                    ret, con = isSameScreen( self.screenNow.backNScreen[0], self.screenNow.currentScreen,self.type)
                except:
                    print("read imge error maybe just dell back1screen maybe")
            #debugInfo(self.screen.back1Screen +self.screen.currentScreen)
        #debugInfo(ret)
            #time.sleep(3)
            if con < 0.95:
                print("图变化了")

            else:
                #debugInfo("图没变化啊")
                pass
            #debugInfo(con)
            return  con









    # def handle_msg_all(self, msg):
    #     """
    #     处理所有消息，请子类化后覆盖此函数
    #     msg:
    #         msg_id  ->  消息id
    #         msg_type_id  ->  消息类型id
    #         user  ->  发送消息的账号id
    #         content  ->  消息内容
    #     :param msg: 收到的消息
    #     """
    #     debugInfo("handle_msg_all----------------------")
    #     pass
    #
    # def handle_msg(self, r):
    #     """
    #     处理原始微信消息的内部函数
    #     msg_type_id:
    #         0 -> Init
    #         1 -> Self
    #         2 -> FileHelper
    #         3 -> Group
    #         4 -> Contact
    #         5 -> Public
    #         6 -> Special
    #         99 -> Unknown
    #     :param r: 原始微信消息
    #     """
    #     # handle messge -------------
    #     debugInfo("handle_msg")
    #     self.handle_msg_all(r)
    #
    # def schedule(self):
    #     """
    #     做任务型事情的函数，如果需要，可以在子类中覆盖此函数
    #     此函数在处理消息的间隙被调用，请不要长时间阻塞此函数
    #     """
    #     debugInfo("schedule")
    #     pass
    #
    # def proc_msg(self):
    #     r = ""
    #     while True:
    #         if self.status == 'ready':
    #             debugInfo("ready to run")
    #             self.status = "run"
    #         else:
    #             debugInfo("running")
    #             pass
    #
    #         try:
    #             self.handle_msg(r)
    #             time.sleep(10)
    #         except:
    #             time.sleep(10)
    #             pass
    #
    #         self.schedule()
    #
    # def run(self):
    #     try:
    #         # zhunbei ok
    #         self.status = 'ready'
    #         self.proc_msg()
    #
    #     except:
    #         debugInfo('error')
    #         self.status = 'out'
    #
    # def init(self):
    #     pass
    #
